import{
    createSlice
} from '@reduxjs/toolkit'
//这个配置对象中自动返回reducer和actions两个属性
const countSlice =createSlice({
    //action中的命名空间
    name:'counter',
    //reducer提供的初始值
    initialState:{
        count:0
    },
    reducers:{
        increment(prev,action){
            prev.count +=action.payload
        },
        decrement(prev,action){
            prev.count -=action.payload
        }
    }
})
export default countSlice.reducer

export const{
    increment,
    decrement
}=countSlice.actions